<template>
	<view class="login">
		<view class="header">
			<!-- <text class="back"></text> -->
			<text class=""></text>
			<text @click="C_loginPassword">快捷登陆</text>
		</view>
		<view class="title">
			<view>账号密码登陆</view>
			<view>输入手机号和密码即可登陆平台</view>
		</view>
		
		<view class="form">
			<view>
				<input type="text" v-model="form.mobile" maxlength="11" placeholder="请输入手机号"/>
			</view>
			<view>
				<input type="password" v-model="form.password" placeholder="请输入密码"/>
			</view>
			<!-- <view v-if="vuex_pid">
				<input v-model="form.code+vuex_pid" disabled  style="color: rgba(0,0,0,.5)"/>
			</view> -->
		</view>
		<view style="display: flex;justify-content: space-between;align-items: center;">
			<text></text>
			<view class="forgetPassword" @click="C_forgetPassword">忘记密码?</view>
		</view>
		
		<view class="xy" @click="isxy = !isxy">
			<image v-if="isxy" :src="vuex_httpImageUrl+ 'static/common/iconxy1.png'" mode="widthFix"></image>
			<image v-else :src="vuex_httpImageUrl+ 'static/common/iconxy.png'" mode="widthFix"></image>
			<view style='display: flex;'>
				<text>请阅读并勾选</text>
				<navigator url="../xieyi">《 协议说明项 》</navigator>
			</view>
		</view>
		<view class="submit" @click="C_submit">登陆</view>
		
		<view class="msg">未注册的用户将自动为您注册</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form:{
					mobile:'',
					password:'',
					code:'推荐码 : '
				},
				isxy:false,
			};
		},
		onLoad() {			
			console.log(this.vuex_token);
			if (this.vuex_token){
				uni.reLaunch({
					url:'/pages/healthy/healthy'
				})
			}
		},
		methods:{
			async C_submit(){
				
				if(!this.isxy){this.$u.toast('请先阅读并勾选协议说明项');return}
				
				let {mobile,password} = this.form;
				let {isMobile} = this.$u.utils.yz;
				
				if(!isMobile(mobile)){this.$u.toast('请输入正确的手机号');return};
				if(!password){this.$u.toast('请输入密码');return};
				
				let params = {mobile,password,code:this.vuex_pid}
				let passlogin = await this.$u.api.passlogin(params) 
				if(passlogin.code == 0){
					this.$u.vuex('vuex_token',passlogin.data.token)
					uni.reLaunch({
						url:'/pages/healthy/healthy'
					})
				}else{
					this.$u.toast(passlogin.msg)
				}
			},
			C_loginPassword(){
				uni.navigateTo({
					url:'../login'
				})
			},
			C_forgetPassword(){
				uni.navigateTo({
					url:'../forgetPassword/forgetPassword'
				})
			}
		}
	}
</script>

<style lang="scss">
	@import "../loginCommon.scss";
	.forgetPassword{
		margin-bottom: 15rpx!important;
	}
	.xy{
		display: flex;
		align-items: center;
		image{
			width: 35rpx;
			height: 35rpx;
			margin-right: 10rpx;
		}
		navigator{
			color: blue;
		}
	}
</style>
